package yxy.cherry.paycenter.channelmodule.sdk_jh;

import java.util.ArrayList;

import org.joda.time.DateTime;

import com.alibaba.fastjson.JSONObject;

import yxy.apple.logger.Logger;
import yxy.cherry.data.bean.charge;
import yxy.cherry.paycenter.channelmodule.PayMoudle_channel;
import yxy.cherry.paycenter.database.db.orders;
import yxy.game.pm2.bean.Currency;
import yxy.game.pm2.bean.PlayerBean;
import yxy.game.pm2.bean.channel.SdkChannel;
import yxy.game.pm2.bean.module.OrderInfoModule;
import yxy.game.pm2.bean.order.OrderInfo;

public class PayMoudle_jh extends PayMoudle_channel {

	static final Logger logger = Logger.create(PayMoudle_jh.class);
	
	private static final String jhorderurl = "https://pay.ofgame.net/pay/order";	//下单地址

	@Override
	public JSONObject dealPay(JSONObject infoobj) {
		return null;
	}

	@Override
	public JSONObject createOrderInfo(JSONObject infoobj, orders o) {
		JSONObject json = new JSONObject();
		String ProductId = String.valueOf(o.getGoodsid());	//商品id
		String OrderID = o.getMyorderid();		//cp订单号
		int Price = o.getGoodsprice();		//金额 必填 单位分
		String productName = o.getGoodsname();		//商品名称 必填
		
		PlayerBean pb = PlayerBean.get(o.getPlayercode());
		
		int RoleLevel = pb.getLevel();
		String RoleId = o.getPlayercode();
		String RoleName = pb.getName();
		
		int ServerId = pb.getServerId();
		String ServerName = ServerId + "服";
		
		json.put("myorderid", o.getMyorderid());
		
		json.put("ProductId", ProductId);
		json.put("OrderID", OrderID);
		json.put("Price", Price);
		json.put("productName", productName);
		json.put("RoleLevel", RoleLevel);
		json.put("RoleId", RoleId);
		json.put("RoleName", RoleName);
		json.put("ServerId", ServerId);
		json.put("ServerName", ServerName);
		
		return json;
	}
	
	public orders createOrderJH(int dataid, String playercode, int serverid, int acttype) {
		orders o = createOrder(getChannel(), dataid, acttype, playercode, serverid);
		addOrder(o);
		return o;
	}
	
	/**
	 * 创建 OrderInfo
	 * @param o
	 * @param curs
	 * @param c
	 * @param payamount
	 */
	public void createOrderInfoModule(orders o, ArrayList<Currency> curs, charge c, int payamount) {
		createOrderInfoModule(o, curs, c.getVipexp(), payamount);
	}
	
	/**
	 * 
	 * @param o
	 * @param curs
	 * @param vipexp
	 * @return
	 */
	public void createOrderInfoModule(orders o, ArrayList<Currency> curs, int vipexp, int payamount) {
		OrderInfo oi = OrderInfoModule.createOrderInfo(o.getGoodsid(), o.getChannel(), o.getMyorderid(), new DateTime(o.getCreatetime().getTime()), 
				OrderInfoModule.orderinforuning, o.getPlatorderid(), o.getActtype(), o.getPlayercode(), curs, 
				o.getServerid(), DateTime.now(), vipexp, payamount, o.getGoodsprice());
		OrderInfo.set(o.getPlayercode(), oi);
	}

	@Override
	public String getChannel() {
		return SdkChannel.sdk_jh;
	}

}
